﻿using GraphProcessor;
using IQIGame.Onigao.Logic;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(LevelEditorConst.Execution + "/" + LevelEditorConst.StartStoryDialog, typeof(LevelServiceGraph))]
    public class LevelServiceExecutionNode_StartStoryDialog : LevelServiceExecutionNode
    {
        protected override ServiceExecutionType mServiceType => ServiceExecutionType.StartStoryDialog;

        public override string name => LevelEditorConst.StartStoryDialog;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.StartStoryDialog, "StoryDialog表ID")]
        public int dialogCid;
        [InspectorName("是否全局剧情"), Tooltip("全局剧情代表所有玩家都会开启(多人游戏使用)")]
        public bool isGlobal;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.StartStoryDialog, "非从头对话的剧情文件ID"), Tooltip("0为从头开始正常对话，自行找所需剧情文件对话ID填入并确保ID前文本不含选项")]
        public int startCid;

        protected override LevelServiceCustomConfig CreateConfig()
        {
            var rConfig = new LevelServiceExecutionCustom_StartStoryDialog()
            {
                dialogCid = this.dialogCid,
                isGlobal = this.isGlobal,
                startCid = this.startCid
            };
            return rConfig;
        }
        
        protected override void OnSync(EditorLevelServiceExecutionConfig newConfig, LevelServiceExecutionNode tempNode)
        {
            if (tempNode is LevelServiceExecutionNode_StartStoryDialog rNode)
            {
                this.dialogCid = rNode.dialogCid;
                this.isGlobal = rNode.isGlobal;
                this.startCid = rNode.startCid;
            }
        }
    }
}